package com.spsy.order.controller;

import com.alibaba.fastjson2.JSON;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.spsy.common.core.domain.R;
import com.spsy.common.core.utils.DateUtils;
import com.spsy.common.vo.OrderAddParamsVo;
import com.spsy.order.domain.Order;
import com.spsy.order.domain.OrderLog;
import com.spsy.order.service.IOrderLogService;
import com.spsy.order.service.IOrderService;
import com.spsy.order.service.OrderOptsService;
import com.spsy.order.vo.OrderAddRequest;
import com.spsy.pay.api.PayApi;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.Date;
import java.util.Random;

/**
 * @author: liuzhiping
 * @date: 2025/5/5 11:40
 **/
@Slf4j
@RestController
@RequestMapping("/order")
public class OrderOptsController {

   /* @Autowired
    private PayApi payApi;

    @Autowired
    private IOrderService iOrderService;

    @Autowired
    private IOrderLogService iOrderLogService;
    */

    @Autowired
    private OrderOptsService orderOptsService;




    /*@PostMapping("/payOrder")
    public  R  payOrder() throws Exception{
        //订单系统 调用 支付系统；下单接口

        String orderId = "order123456789";
        this.payApi.payOrder(orderId);

        return R.ok();
    }*/


    @PostMapping("/payOrder2")
    public  R  payOrder2(@RequestBody OrderAddRequest orderAddRequest) throws Exception{
        //订单系统 调用 支付系统；下单接口

        log.info("参数 orderAddRequest:{}", JSON.toJSONString(orderAddRequest));


        return this.orderOptsService.sendPayOrder(orderAddRequest);


    }
}
